<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>加减计数器</title>
    <link href="./index.css" rel="stylesheet" />
</head>

<body>
    <!-- 页面主结构 -->
    <div id="app">
        <!-- 计数器功能区域 -->
        <div class="input-num">
            <!-- 减号按钮 -->
            <button @click="decrement">-</button>
            <!-- 显示计数值 -->
            <span>{{ count }}</span>
            <!-- 加号按钮 -->
            <button @click="increment">+</button>
        </div>
    </div>

    <!-- 引入Vue.js库 -->
    <script src="../js/vue.js"></script>

    <!-- Vue实例 -->
    

    <script>
        var app = new Vue({
            el: "#app", // 挂载点
            data: {
                count: 0 // 初始计数值
            },
            methods: {
                increment() {
                    this.count++; // 增加计数
                },
                decrement() {
                    if (this.count > 0) {
                        this.count--; // 减少计数（限制为非负）
                    }
                }
            }
        });
    </script>
</body>

</html>